<%+header%>                                                                  
<div class="fourcontainers">
    <div class="fourSetting">
        <form action="" id="netForm">
            <div class="modelNode">
                <span>4G网络状态</span>
				<input type="text" class="fourSetInput" disabled />
            </div>
            <div class="serverType">
                <span>4G网络配置</span>
                <select name="open4g" id="fourSetSelect" class="fourSetSelect">
                    <option value="1">开启</option>
                    <option value="0">关闭</option>
                </select>                
            </div>
            <div class="serverType" style="display: none;">
                <span></span>                 
				<input name="click" type="text" class="sureClick" style="display:none;"/>              
            </div>
            <div class="fourOp">
                <button type="submit" class="fourSaveApply">配置</button>
            </div>
        </form>
    </div>
</div>
<script>
	var openf = "<%=openf%>"
	console.log(openf);
	var i4g = "<%=i4g%>"
	console.log(i4g);

	if(openf == 1){
		$('.fourSetInput').val('4G已开启');
		$('.fourSetSelect').val(1);
	} else{
		$('.fourSetInput').val('4G已关闭');
		$('.fourSetSelect').val(0);
	}
        var itemss=sessionStorage.getItem("index");
        $(window).scroll(function(){//开始监听滚动条
            var topp = $(document).scrollTop();
	    $('.fourcontainers').css('top',490-topp);
	    $('#type'+ itemss).siblings().css('top',174-topp);
            if(topp > 65){
		$('header').css('visibility',"hidden");
            }else{
   		$('header').css('visibility',"visible");
	    }
        });
	$('.sureClick').val(0);
	var index;
    $('.fourSaveApply').on('click',function () {
		var netKey = $('.fourSetSelect').val();
		$('.sureClick').val(1);
		
		if((openf == 1)&&(netKey == 0)){
			$('.fourSetInput').val('4G正在关闭...');
			index = layer.load(0, {shade: false});
			registPost();
	        event.preventDefault();
		} else if((openf == 0)&&(netKey == 1)){
			$('.fourSetInput').val('4G正在开启...');
			index = layer.load(0, {shade: false});
			registPost();
	        event.preventDefault();
		} else {
			layer.tips('请选择正确的开关方式', '#fourSetSelect',{
			    tips: [2, '#78BA32']
			});
			event.preventDefault();
		}

    });

    function registPost () {
        $.ajax({
            type: "post",
            url: "<%=REQUEST_URI%>",
            data: $('#netForm').serialize()
        }).success(function(message) {
            console.log(message);
			layer.close(index);
			window.location.reload();
        }).fail(function(err){
            console.log(err);
        })
    }
</script>
<%+footer%>